(() => {
    let ele = {};
    ele.list = $('#list');
    ele.kong = $('#kong');

    getnews()
    function getnews() {
        let token = getCookie("token");
        let userid = getCookie("userid");
        ajax({
            url: API_PATH.GETNEWLIST,
            method: 'GET',
            header: {
                Authorization: token
            },
            success: res => {
                if (res.data == '') {
                    ele.kong.style.display = 'block'
                } else {
                    drawinfo(res.data)
                }

            }
        });
    }

    function drawinfo(data) {
        let html = '';
        for (let i = 0; i < data.length; i++) {
            let d = data[i];
            html += '<div class="list" onclick="tz(' + d.id + ')">' +
                '<div class="alin">' +
                '<p class="des">' + d.title + '</p>' +
                '<p class="time">' + d.created_at + '</p>' +
                '</div>' +
                '<img class="arrow" src="http://img.qunx.top/xianwang/self/arrow.png" alt="">' +
                '</div>';
        }
        ele.list.innerHTML += html;
    }

    window.tz = function tz(id) {
        location.href = 'notice_detail.html?id=' + id
    }



})();